package com.sxm.yiwei.adapters;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.sxm.yiwei.R;

import java.util.List;

/**
 * Created by KuKa on 2017/10/16.
 */

public class HopeStoreGridAdapter extends BaseAdapter {
    Context context;
    List<Integer> mList;

    public HopeStoreGridAdapter(Context context, List<Integer> mList) {
        this.context = context;
        this.mList= mList;
    }

    @Override
    public int getCount() {
        return mList.size()==0?0:mList.size();
    }

    @Override
    public Object getItem(int position) {
        return mList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        View view;
        if (convertView==null){
            view = LayoutInflater.from(context).inflate(R.layout.hopestore_griditem,null);
            holder = new ViewHolder();
            holder.gridprice = (TextView) view.findViewById(R.id.hopestore_gridprice);

            view.setTag(holder);

        }else {
            view = convertView;
            holder = (ViewHolder) view.getTag();
        }
        holder.gridprice.setText(mList.get(position)+" 元/单");
        return view;
    }

    class ViewHolder{
        TextView gridprice;
    }
}
